<?php

App::uses('AppModel', 'Model');
App::uses('SimplePasswordHasher', 'Controller/Component/Auth');

class User extends AppModel {
    
    public function beforeSave($options = array())
    {
        if(!$this->id)
        {
            $passwordHasher = new SimplePasswordHasher();
            $this->data['User']['pass'] = $passwordHasher->hash($this->data['User']['pass']);
        }
        return true;
    }
    
    public function hashea($passA)
    {
        $passwordHasher = new SimplePasswordHasher();
        return $passwordHasher->hash($passA);
    }
    public function regresaBase()
    {
        return $this->getDataSource();
    }
    public function ultimoId()
    {
        $id = $this->find('first',array(
            'fields' => 'id',
            'order' => 'id DESC',
            'callbacks' => false,
          ));
        $id = $id['User']['id'];
        return $id;
    }
}
